﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Media;

namespace WindowsFormsApplication1
{
    public partial class slideShowOption : Form
    {
        Form1 aForm1;
        List<string> slideShowImageLocations;

        public slideShowOption(Form1 theForm1, List<string> theSlideShowImageLocations)
        {
            InitializeComponent();
            aForm1 = theForm1;
            slideShowImageLocations = theSlideShowImageLocations;

            comboBox1.SelectedItem = theForm1.dcolor;
            comboBox2.SelectedItem = theForm1.dsound;
            comboBox3.SelectedItem = theForm1.dtime;
            comboBox5.SelectedItem = theForm1.drep;
        }

        private void button1_Click(object sender, EventArgs e)
        {



            aForm1.dcolor = (string) comboBox1.SelectedItem;
            aForm1.dsound = (string)comboBox2.SelectedItem;
            aForm1.dtime = (string)comboBox3.SelectedItem;
            aForm1.drep = (string)comboBox5.SelectedItem;




            Close();
            aForm1.WindowState = System.Windows.Forms.FormWindowState.Minimized;

            SlideShow ss = new SlideShow(aForm1);

            switch ((string) comboBox1.SelectedItem)
            {
                case "Black":
                    ss.BackColor = Color.Black;
                    break;
                case "Blue":
                    ss.BackColor = Color.Blue;
                    break;
                case "Green":
                    ss.BackColor = Color.Green;
                    break;
                case "Orange":
                    ss.BackColor = Color.Orange;
                    break;
                case "Purple":
                    ss.BackColor = Color.Purple;
                    break;
                case "Red":
                    ss.BackColor = Color.Red;
                    break;
                case "White":
                    ss.BackColor = Color.White;
                    break;
                case "Yellow":
                    ss.BackColor = Color.Yellow;
                    break;
            }


            switch ((string)comboBox3.SelectedItem)
            {
                case "1 Second":
                    ss.time = 1000;
                    break;
                case "2 Seconds":
                    ss.time = 2000;
                    break;
                case "3 Seconds":
                    ss.time = 3000;
                    break;
                case "4 Seconds":
                    ss.time = 4000;
                    break;
                case "5 Seconds":
                    ss.time = 5000;
                    break;
                case "10 Seconds":
                    ss.time = 10000;
                    break;
                case "30 Seconds":
                    ss.time = 30000;
                    break;
                case "1 Minute":
                    ss.time = 60000;
                    break;
            }

            switch ((string)comboBox5.SelectedItem)
            {
                case "Off":
                    ss.repeat = false;
                    break;
                case "On":
                    ss.repeat = true;
                    break;
            }

            string soundClipLocation;

            switch ((string)comboBox2.SelectedItem)
            {
                case "Chime":
                    ss.soundOn = true;
                    soundClipLocation = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", "\\Sounds\\chimes.wav");
                    ss.sound = new SoundPlayer(soundClipLocation);
                    break;
                case "Click":
                    ss.soundOn = true;
                    soundClipLocation = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", "\\Sounds\\start.wav");
                    ss.sound = new SoundPlayer(soundClipLocation);
                    break;
                case "Ding":
                    ss.soundOn = true;
                    soundClipLocation = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", "\\Sounds\\ding.wav");
                    ss.sound = new SoundPlayer(soundClipLocation);
                    break;
                case "None":
                    ss.soundOn = false;
                    break;
            }

            ss.paths = slideShowImageLocations;

            ss.Show();

            ss.showShow();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void comboBox2_SelectedValueChanged(object sender, EventArgs e)
        {
            string soundClipLocation;
            SoundPlayer sp;

            switch ((string)comboBox2.SelectedItem)
            {
                case "Chime":
                    soundClipLocation = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", "\\Sounds\\chimes.wav");
                    sp = new SoundPlayer(soundClipLocation);
                    sp.Play();
                    break;
                case "Click":
                    soundClipLocation = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", "\\Sounds\\start.wav");
                    sp = new SoundPlayer(soundClipLocation);
                    sp.Play();
                    break;
                case "Ding":
                    soundClipLocation = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", "\\Sounds\\ding.wav");
                    sp = new SoundPlayer(soundClipLocation);
                    sp.Play();
                    break;
                case "None":
                    break;
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch ((string)comboBox1.SelectedItem)
            {
                case "Black":
                    comboBox1.BackColor = Color.Black;
                    break;
                case "Blue":
                    comboBox1.BackColor = Color.Blue;
                    break;
                case "Green":
                    comboBox1.BackColor = Color.Green;
                    break;
                case "Orange":
                    comboBox1.BackColor = Color.Orange;
                    break;
                case "Purple":
                    comboBox1.BackColor = Color.Purple;
                    break;
                case "Red":
                    comboBox1.BackColor = Color.Red;
                    break;
                case "White":
                    comboBox1.BackColor = Color.White;
                    break;
                case "Yellow":
                    comboBox1.BackColor = Color.Yellow;
                    break;
            }
/*

            ComboBoxItem cmi = new ComboBoxItem();
            cmi.Background = new SolidColorBrush(Color.FromArgb(255, 128, 0, 123));
            cmi.Content = "test new item";
            comboBox1.Items.Add(cmi);
            */
        }

        private void comboBox1_DropDown(object sender, EventArgs e)
        {
            comboBox1.BackColor = Color.White;
        }

        private void comboBox1_DropDownClosed(object sender, EventArgs e)
        {
            switch ((string)comboBox1.SelectedItem)
            {
                case "Black":
                    comboBox1.BackColor = Color.Black;
                    break;
                case "Blue":
                    comboBox1.BackColor = Color.Blue;
                    break;
                case "Green":
                    comboBox1.BackColor = Color.Green;
                    break;
                case "Orange":
                    comboBox1.BackColor = Color.Orange;
                    break;
                case "Purple":
                    comboBox1.BackColor = Color.Purple;
                    break;
                case "Red":
                    comboBox1.BackColor = Color.Red;
                    break;
                case "White":
                    comboBox1.BackColor = Color.White;
                    break;
                case "Yellow":
                    comboBox1.BackColor = Color.Yellow;
                    break;
            }
        }

        private void comboBox1_DragOver(object sender, DragEventArgs e)
        {
       
        }

        private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            System.Console.WriteLine("sdfasd");

            if (e.Index == -1)
            {
                return;
            }

            //user mouse is hovering over this drop-down item, update its data  
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {


                           switch ((string)comboBox1.Items[e.Index].ToString())
            {
                case "Black":
                    comboBox1.BackColor = Color.Black;
                    break;
                case "Blue":
                    comboBox1.BackColor = Color.Blue;
                    break;
                case "Green":
                    comboBox1.BackColor = Color.Green;
                    break;
                case "Orange":
                    comboBox1.BackColor = Color.Orange;
                    break;
                case "Purple":
                    comboBox1.BackColor = Color.Purple;
                    break;
                case "Red":
                    comboBox1.BackColor = Color.Red;
                    break;
                case "White":
                    comboBox1.BackColor = Color.White;
                    break;
                case "Yellow":
                    comboBox1.BackColor = Color.Yellow;
                    break;
            }
            }
          
        }

     
    }
}
